<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../commons/taglibs.jsp"%>
<%@ include file="../../commons/list.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta charset="utf-8">
  <title>车系在售管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <style type="text/css">
  	input{
  		width: 200px;
  		display: inline;
  	}
  </style>
</head>

<body>

<div>
	<div style="padding: 50px;padding-top: 100px">
		<form class="layui-form layui-form-pane"  action="">
		<input type="hidden" id='entityId' name='entityId' value="${carClassify.id }">
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 60px">
		     <label class="layui-form-label">类别名称</label>
		    <div class="layui-input-block">
			     <select name="carcategoryid" lay-verify="required" lay-search="">
			        <option value=""></option>
			     	<c:forEach items="${carCategoryList}" var="carCategory">
		     			<c:if test="${carCategory.carcategoryid eq carClassify.carcategoryid}">
				        	<option value="${carCategory.carcategoryid }" selected>${carCategory.carcategoryname}</option>
		     			</c:if> 
			     		
			     		<c:if test="${carCategory.carcategoryid ne carClassify.carcategoryid}">
					        <option value="${carCategory.carcategoryid}">${carCategory.carcategoryname}</option>
			     		</c:if> 
			     	</c:forEach>
		      	</select>
		    </div>
		  </div>
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 60px">
		     <label class="layui-form-label">在售情况</label>
		    <div class="layui-input-block">
		   	  <select name="carclassifyid" lay-verify="required" lay-search="">
			        <option value=""></option>
			        <c:if test="${carClassify.carclassifyid eq '1' }">
				        <option value="1" selected>在售车型</option>
				        <option value="2">停售车型</option>
			        </c:if>
			         <c:if test="${carClassify.carclassifyid eq '2' }">
			          	<option value="1">在售车型</option>
				        <option value="2" selected>停售车型</option>
			        </c:if>
			        <c:if test="${empty carClassify.carclassifyid}">
			        	<option value="1">在售车型</option>
				        <option value="2">停售车型</option>
			        </c:if>
		      	</select>
		    </div>
		  </div>
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 150px;padding-top: 30px">
		    <div class="layui-input-block">
		      <button class="layui-btn" id='tjsub' lay-submit lay-filter="formDemo">立即提交</button>
		      <a class="layui-btn" onclick="closeWindow()"><i class="layui-icon">&#xe65c;</i>返回</a>
		    </div>
		  </div>
		</form>
	</div>
 </div>
<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
	  //提交成功后禁用按钮
	  $("#tjsub").css("pointer-events","none"); 
	  $.post('<%=basePath%>controller/carClassify/save',data.field,function(data){
		  if(data == '1'){
			  $("#tjsub").css("pointer-events","auto");
			  layer.msg('提交失败', {time:1000});
		  }
		  if(data == '2'){
			  $("#tjsub").css("pointer-events","auto");
			  layer.msg('车系类别已存在', {time:1000});
		  }
		  if(data == '0'){
			  var entityId=$("#entityId").val();
              if(entityId==''||entityId==null){
				  layer.msg('提交成功', {time:1000});
				  parent.window.addReload();
              }else{
            	  layer.msg('提交成功', {time:1000});
				  parent.window.editReload();
              }
              //当你在iframe页面关闭自身时
			  var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			  setTimeout("parent.layer.close("+index+")",1000);
		  }
	  })
    return false;
  });
});
//返回按钮事件
function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
} 

</script>
</body>
</html>
